<template>
  <div id="setting">  
     <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">信用系统</div>
     </div> 
    <el-row>
        <el-col :span="24" style="text-align: right;">    
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png" />添加
            </el-button>
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="set_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />设置
            </el-button>        
        </el-col>
    </el-row>

   <!-- 渲染数据list -->
   <credit-list :datalist="datalist" @up_list_fun="list_fun"> </credit-list>

    

     <!-- 信用分对应值 -->
    <el-dialog title="信用分对应值" :visible.sync="num_mtk"  width="400px">
        <div style="width:100%;"> 

                <el-form ref="form"   label-width="50px" style="width:100%;">
            
                    <el-form-item :label="variable_name1" label-width="">
                         <el-input    v-model="num_form.gm" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item :label="variable_name2" label-width="">
                         <el-input    v-model="num_form.jd" placeholder="请输入"></el-input>
                    </el-form-item>
                     <el-form-item label="上线" label-width="">
                         <el-input    v-model="num_form.number" placeholder="请输入上线"></el-input>
                    </el-form-item>
               </el-form>
                <div style="text-align: center;width:50%;margin:auto;">
                        <el-button type="primary" class="custom_color_button" style="width:80%;" @click="set_qr()">确认</el-button>
                </div>
        </div> 
    </el-dialog>

      
  </div>
</template>

<script>
import CreditList from '@/view/Guomi/CreditList'
export default {
  name: 'setting',
  data () {
    return {
        datalist:[],
        num_mtk:false,
        num_form:{
           gm:'',
           jd:'',
           number:''
        },
        arr:[]
    }
  },
 components:{
    CreditList
  },
  created(){
     
  },
  mounted (){
        this.list_fun()
        this.set_fun()
  },
  methods: { 
        list_fun(){
              this.post("/credit/creditGradeList", {
            }).then(res => {
                this.datalist = res.result 
                console.log(res.result )
            })
        },
        set_fun(){
              this.post("/credit/scaleList", {
            }).then(res => {
               
                console.log(res.result )

                 for(let a of res.result) {
                   if(a.variable == "credit_score_day_upper_limit"){
                       this.num_form.number = a.value
                   }else if(a.variable == "credit_score_need_use_gdb"){
                       this.num_form.jd = a.value
                   }else if(a.variable == "credit_score_need_use_kmb"){
                        this.num_form.gm = a.value
                   }
                }
            })
        },
        set_but(){
            this.arr = []
            this.num_mtk = true          
        },
        set_qr(){
            this.arr = [{"variable":"credit_score_day_upper_limit","value":this.num_form.number},
            {"variable":"credit_score_need_use_gdb","value":this.num_form.jd},{"variable":"credit_score_need_use_kmb","value":this.num_form.gm}]

             this.post("/credit/eidtScale", {
                   arr:this.arr
            }).then(res => {

                    if(res.error_code == 0){
                      this.open1(res.result,'success')  //提示框
                      this.set_fun()
                      this.num_mtk = false      
                    }else {
                      this.open1(res.message,'warning')
                    }

            })
        }
  }
}
</script>


<style scoped>
.avatar-uploader  {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 150px;
    height: 150px;
    line-height: 150px;
    text-align: center;
  }
  .avatar {
    width: 150px;
    height: 150px;
    display: block;
  }
</style>
